package com.test;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.telephony.TelephonyManager;
import android.widget.Toast;

import com.helloworld.R;

public class MainActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		String readAbleAndroidVersion = android.os.Build.VERSION.RELEASE;
		if(readAbleAndroidVersion.contains("1.5")){
			Toast.makeText(this, "du køre 2.1", Toast.LENGTH_LONG).show();

		}
		//Toast.makeText(this, getPhoneinfo(), Toast.LENGTH_LONG).show();
		
		
	}
	
	public String getWifi() {
		String wifiname = null;

		WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		wifiname = wifiManager.getConnectionInfo().toString();
		return wifiname;
	}

	public String getPhoneinfo() {
		String Phoneinfo = null;
		TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
		Phoneinfo = telephonyManager.getDeviceId().toString();
		return Phoneinfo;
	}
	
	public String getip(){
	
	
	WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
	WifiInfo wifiInfo = wifiManager.getConnectionInfo();
	int ipAddress = wifiInfo.getIpAddress();
	
	return String.format("%d.%d.%d.%d",
			(ipAddress & 0xff),
			(ipAddress >> 8 & 0xff),
			(ipAddress >> 16 & 0xff),
			(ipAddress >> 24 & 0xff));
	
	
	}
	public String getname(){
		String rt = null;
		
		
		
		String[] name = new String[]{
								People._ID,
								People._COUNT,
								People.NAME,
								People.NUMBER
		};
		Uri contacts = People.CONTENT_URI;
		Cursor managedcursor = managedQuery(contacts, name, null, null, People.NAME);
		
		rt = managedcursor.getString(1);
		
		return rt;
	}
}